// Copyright (c) [Year] [name of copyright holder]
// [Software Name] is licensed under Mulan PSL v2.
// You can use this software according to the terms and conditions of the Mulan PSL v2. 
// You may obtain a copy of Mulan PSL v2 at:
//          http://license.coscl.org.cn/MulanPSL2 
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.  
// See the Mulan PSL v2 for more details.

#ifndef MY_FUNCTION_HPP
#define MY_FUNCTION_HPP

#include"mystd.hpp"

namespace my{
    using stdTypeOp = typeOp<bool, char, wchar_t, short, int, long, long long, unsigned char, unsigned short, unsigned int, unsigned long, unsigned long long, size_t, float, double>;

    template<typename TYPE, bool B>
    struct func_comp_select;

    template<typename TYPE>
    struct func_comp_select<TYPE, true>{
        static inline int ret(const TYPE & lhs, const TYPE & rhs){
            if(lhs > rhs) return 1;
            else if(lhs < rhs) return -1;
            else return 0;
        } 
    };

    template<typename TYPE>
    struct func_comp_select<TYPE, false>{
        static inline int ret(const TYPE & lhs, const TYPE & rhs){
            return TYPE::comp(lhs, rhs);
        } 
    };
    
    template<typename TYPE>
    struct func{
        static int comp(const TYPE & lhs, const TYPE & rhs){
            return func_comp_select<TYPE, stdTypeOp::func_include<TYPE>::value || std::is_pointer<TYPE>::value>::ret(lhs, rhs);
        }
    };
}
#endif
